<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel header="Search Purchase Orders" >
                        <f:facet name="header" >
                            <h:panelGroup>
                                <p:panelGrid columns="5">
                                    <h:inputText autocomplete="off" id="txtSearch" value="#{billSearch.txtSearch}" style="width: 600px;" >
                                        <f:ajax render="tblBills" execute="txtSearch" event="keyup" />
                                    </h:inputText>

                                    <h:outputLabel value="From Date"/>
                                    <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{billSearch.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >
                                        <f:ajax event="dateSelect" execute="tblBills"  render="tblBills toDate fromDate"/>
                                    </p:calendar>
                                    <h:outputLabel value="To Date"/>
                                    <p:calendar id="toDate" value="#{billSearch.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >
                                        <f:ajax event="dateSelect" execute="tblBills"  render="tblBills toDate fromDate"/>
                                    </p:calendar>
                                </p:panelGrid>
                                <p:watermark value="Search by Bill Id (with or without letters), Patient Name or Phone Number" for="txtSearch" />
                            </h:panelGroup>
                        </f:facet>

                        <p:dataTable id="tblBills" value="#{billSearch.grns}" var="bill"  >
                            <p:column headerText="Bill No" >
                                <h:commandLink action="pharmacy_reprint_grn" value="#{bill.deptId}">
                                    <h:outputLabel  ></h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmacyBillSearch.bill}"/>
                                </h:commandLink>
                            </p:column>                           
                            <p:column headerText="Dealor :" >
                                <h:commandLink action="pharmacy_reprint_grn" value="#{bill.toInstitution.name} - #{bill.toDepartment.name}">
                                    <h:outputLabel  ></h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmacyBillSearcphBillll}"/>
                                </h:commandLink>
                            </p:column>
                            <p:column headerText="Date" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel value="#{bill.createdAt}" >
                                        <f:convertDateTime pattern="dd MM yyyy"/>
                                    </h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmacyBillSeaphBillbill}"/>
                                </h:commandLink>
                            </p:column>
                            <p:column headerText="Time" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel value="#{bill.createdAt}" >
                                        <f:convertDateTime pattern="hh:mm a"/>
                                    </h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmacyBillSphBillh.bill}"/>
                                </h:commandLink>
                            </p:column>                           
                            <p:column headerText="Billed By" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel value="#{bill.creater.webUserPerson.name}" ></h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmacyBilphBillrch.bill}"/>
                                </h:commandLink>
                            </p:column>                                                      
                            <p:column headerText="Net Value" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel value="#{bill.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmacyBphBillearch.bill}"/>
                                </h:commandLink>
                            </p:column>
                            <p:column headerText="Cancelled User" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel rendered="#{bill.cancelled}" value="#{bill.cancelledBill.creater.webUserPerson.name}" ></h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmacphBilllSearch.bill}"/>
                                </h:commandLink>
                            </p:column>
                            <p:column headerText="Cancelled Date and Time" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel rendered="#{bill.cancelled}" value="#{bill.cancelledBill.createdAt}" >
                                        <f:convertDateTime pattern="dd MM yy hh:mm a"/>
                                    </h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pharmphBillillSearch.bill}"/>
                                </h:commandLink>
                            </p:column>   
                            <p:column headerText="Refunded By" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel rendered="#{bill.refunded}" value="#{bill.refundedBill.creater.webUserPerson.name}" ></h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{phaphBillyBillSearch.bill}"/>
                                </h:commandLink>
                            </p:column>
                            <p:column headerText="Refunded Date and Time" >
                                <h:commandLink action="pharmacy_reprint_grn" >
                                    <h:outputLabel rendered="#{bill.refunded}" value="#{bill.refundedBill.createdAt}" >
                                        <f:convertDateTime pattern="dd MM yy hh:mm a"/>
                                    </h:outputLabel>
                                    <f:setPropertyActionListener value="#{bill}" target="#{pphBillacyBillSearch.bill}"/>
                                </h:commandLink>
                            </p:column>
                            <p:column headerText="Comments" >
                                <h:outputLabel rendered="#{bill.refundedBill ne null}" value="#{bill.refundedBill.comments}" >
                                </h:outputLabel>
                                <h:outputLabel  rendered="#{bill.cancelledBill ne null}" value="#{bill.cancelledBill.comments}" >
                                </h:outputLabel>
                            </p:column>
                        </p:dataTable>


                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
